package cn.eoeit.mmy.bean;


/**
 * <br>
 * <功能描述>
 *
 * @author Java-007 2015年2月7日
 *
 */
public class Response {

    public static final String SUCCESS_CODE = "0000";
    public static final String ERROR_CODE = "0001";
    public static final String MISSING_CODE = "0002";

    private String code;
    private String message;
    private Object result;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getResult() {
    	if (null == result) {
			return "";
		}
    	 return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public static Response getSuccess() {
        Response r = new Response();
        r.code = SUCCESS_CODE;
        r.message="success";
        r.result ="";
        return r;
    }

    public static Response getSuccess(Object result) {
        Response r = new Response();
        r.code = SUCCESS_CODE;
        r.result = result;
        r.message="success";
        return r;
    }

    public static Response getError(String message) {
        Response r = new Response();
        r.code = ERROR_CODE;
        r.message = message;
        return r;
    }

    public static Response buildSuccess(Object result, String message) {
        Response r = new Response();
        r.code = SUCCESS_CODE;
        r.result = result;
        r.message = message;
        return r;
    }
    
    public static Response buildSuccess(String code,Object result, String message) {
        Response r = new Response();
        r.code = code;
        r.result = result;
        r.message = message;
        return r;
    }
    
    public static Response buildErrorWithMissing() {
        Response r = new Response();
        r.code = MISSING_CODE;
        r.result = null;
        r.message = "lack of required parameters Or test data error"; //缺少数据参数或测试数据错误。
        return r;
    }

}